I have a database with a large number of projects, each with many modules. Within the database, we also have a "Sandbox" folder for users to try stuff before performing the same thing on the real module. I am performing a search through the database for a modules containing a specified string, but don't want to search through any modules within the Sandbox. The issue I have is that the Sandbox folder isn't necessarily always going to be the direct parent of a module. How would I check if a module is located somewhere within the sandbox's folder? I know it would have something to do with using a parent function, but not sure how to make it check the grandparent (or great-grandparent, etc. folder, if there is one).
Chris chrscote - Mon Dec 04 11:11:00 EST 2017 |
Re: How to determine if module in specific folder
Module m = current
string FolderToBeFound = "Sandbox"
Folder f = getParentFolder m
bool found = false
while (!null f) {
if (name f == FolderToBeFound) {
found = true
break
}
f = getParentFolder f
}
print "Module " (fullName m) " is" (found ? "" :" not") " located in a folder called " FolderToBeFound ".\n"
|
Re: How to determine if module in specific folder Option A.) See rootName_ in https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014240694#77777777-0000-0000-0000-000014240718 Then if the returned module path matches Sandbox (i.e. if (matches("Sandbox", ModulePath)) ) , then the module is in Sandbox. Or in some other folder named Sandbox :-) Option B.) To check the folders you would have to recursively climb up from the module with getParentFolder function until the returned getParentFolder is null (database root has no parent) and break if along the way there was a Sandbox folder. |